package com.example.demo.controller;

import com.example.demo.dto.NurPatientRelDTO;
import com.example.demo.entity.NurPatientRel;
import com.example.demo.entity.Nurse;
import com.example.demo.entity.SocType;
import com.example.demo.enums.ResultEnum;
import com.example.demo.service.SocService;
import com.example.demo.service.VistorService;
import com.example.demo.vo.ResultVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import java.sql.Date;
import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/soc")
public class SocController {
    @Autowired
    private SocService socService;

    @RequestMapping("/addSocType")
    public ResultVO addSocType(String typename){
        int result = socService.addSocType(typename);
        return new ResultVO(ResultEnum.SUCCESS,result);
    }

    @RequestMapping("/findSocType")
    public ResultVO findSocType(){
        List<SocType> lists = socService.findSocType();
        return new ResultVO(ResultEnum.SUCCESS,lists);
    }

    @RequestMapping("/findAllNurse")
    public ResultVO findAllNurse(){
        List<Nurse> lists = socService.findAllNurse();
        return new ResultVO(ResultEnum.SUCCESS,lists);
    }

    @RequestMapping("/findNurseByPage")
    public ResultVO findNurseByPage(String startNum,String size){
        List<Nurse> lists = socService.findNurseByPage(Integer.valueOf(startNum),Integer.valueOf(size));
        return new ResultVO(ResultEnum.SUCCESS,lists);
    }

    @RequestMapping("/nurPatientRel")
    public ResultVO nurPatientRel(@RequestParam Map<String,String> map){
        int result = socService.nurPatientRel(map);
        return new ResultVO(ResultEnum.SUCCESS,result);
    }

    @RequestMapping("/findAllRel")
    public ResultVO findAllRel(String startNum,String size){
        Integer num1 = Integer.valueOf(startNum);
        Integer num2 = Integer.valueOf(size);
        List<NurPatientRelDTO> lists = socService.findAllRel(num1,num2);
        return new ResultVO(ResultEnum.SUCCESS,lists);
    }

    @RequestMapping("/findRelTotal")
    public ResultVO findRelTotal(){
        int result = socService.findRelTotal();
        return new ResultVO(ResultEnum.SUCCESS,result);
    }

    @RequestMapping("/findNurseTotal")
    public ResultVO findNurseTotal(){
        int result = socService.findNurseTotal();
        return new ResultVO(ResultEnum.SUCCESS,result);
    }

    @RequestMapping("/addNurse")
    public ResultVO addNurse(@RequestParam Map<String,String> map){
        int result = socService.addNurse(map);
        return new ResultVO(ResultEnum.SUCCESS,result);
    }
    @RequestMapping("/updateNurse")
    public ResultVO updateNurse(@RequestParam Map<String,String> map){
        int result = socService.updateNurse(map);
        return new ResultVO(ResultEnum.SUCCESS,result);
    }
    @RequestMapping("/delNurse")
    public ResultVO delNurse(String nid){
        int result = socService.delNurse(Integer.valueOf(nid));
        return new ResultVO(ResultEnum.SUCCESS,result);
    }


}
